﻿using Dapper;
using DBOptionPro.DBUtils;
using DBOptionPro.Model;
using DevExpress.Utils.Gesture;
using DevExpress.XtraPrinting;
using MySqlX.XDevAPI.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ubiety.Dns.Core;
using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames;

namespace DBOptionPro.DAL
{
    /// <summary>
    /// 同步数据库访问类(本地数据库文件)
    /// </summary>
    public class MyDataDAL : DBHelper<MyData>
    {

        public MyDataDAL(DBFileInfo file, SysOption option, List<MyArea> areas) : base(file.FilePath)
        {
            _File = file;
            _Option = option;
            _Areas = areas;

        }

        public MyDataDAL(DBFileInfo file) : base(file.FilePath)
        {
            _File = file;
        }


        private readonly DBFileInfo _File;
        private readonly SysOption _Option;
        private readonly List<MyArea> _Areas;


        /// <summary>
        /// 
        /// </summary>
        /// <param name="table">表名(要从哪个表查数据)</param>
        /// <param name="field">字段名(要取数据的字段名)</param>
        /// <param name="where">查询条件，sql条件拼接(这个是查询条件，例如  字段1=@feid1 and 字段2=@feild2)</param>
        /// <param name="par">条件参数(new { 参数1 = 值1, 参数2 = 值 2}),注意这个参数1、参数2的名称与上面@feid1、@feid2要对应</param>
        /// <returns></returns>
        private T Getfv<T>(string table, string field, string where, object par)
        {
            try
            {
                if (_DBConnection.State != ConnectionState.Open)
                {
                    _DBConnection.Open();
                }
                string sql = $"select {field} from {table} where {where}";

                return _DBConnection.ExecuteScalar<T>(sql, par);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return default;
            }


        }
        private string Getxkkm(string xkkmstr)
        {
            string outstr = "";
            if (!string.IsNullOrEmpty(xkkmstr))
            {

                string[] xkkmarr = xkkmstr.Split('*');
                foreach (string element in xkkmarr)
                {
                    string outstr1 = Getfv<string>("td_kmdm", "kmmc", "kmdm=@kmdm", new { kmdm = element });
                    if (!string.IsNullOrEmpty(outstr))
                    {
                        outstr = outstr + '*' + outstr1;
                    }
                    else
                    {
                        outstr = outstr1;
                    }
                }
            }
            return outstr;
        }
        private DataTable Getfvlist(string table, string field, string where, object par)
        {
            if (_DBConnection.State != ConnectionState.Open)
            {
                _DBConnection.Open();
            }
            string sql = $"select {field} from {table} where {where}";
            DataTable dtlist = base.GetDataTable(sql, par);
            return dtlist;

        }

        /// <summary>
        /// 获取同步数据
        /// </summary>
        /// <param name="sourFields">成绩字段字典</param>
        /// <returns></returns>
        public List<MyData> GetMyDatas(Dictionary<string, string[]> sourFields)
        {
            List<MyData> datas = new List<MyData>();
            string sql = GetSQL();
            if (string.IsNullOrWhiteSpace(sql)) return new List<MyData>();
            if (_File.FileExtension.ToLower() == ".fdb")
            {
                //datas = base.QueryList(sql, null).ToList();
                DataTable dtf = base.GetDataTable(sql);
                foreach (DataRow row in dtf.Rows)
                {

                    MyData myData = new MyData();
                    if (!string.IsNullOrEmpty(Convert.ToString(row["lqzy"]).Trim()) && Convert.ToString(row["lqzy"]).Trim() != "?")
                    {
                        myData.zslqztdm = "1";
                    }
                    else
                    {
                        myData.zslqztdm = "0";
                    }
                    //Console.WriteLine(row["ksh"]);//打印第一行的zymc字段
                    myData.year = (string)row["year"];
                    myData.ksh = (string)row["ksh"];
                    myData.xm = (string)row["xm"];
                    //xb = (string)row["xb"],
                    //myData.xb = Getfv<string>("TD_XBDM", "XBMC", "XBDM=@xbdm", new { xbdm = row["xbdm"] });
                    myData.xb = Convert.ToString(row["xb"]);
                    myData.xbdm = (string)row["xbdm"];
                    myData.zsdiqu = (string)row["zsdiqu"];
                    myData.zsdiqudm = (string)row["zsdiqudm"];
                    //44广东特殊处理列
                    if (Convert.ToString(row["zsdiqudm"]) == "44")
                    {
                        myData.kl = Getfv<string>("td_jhlbdm", "jhlbmc", "jhlbdm=@jhlbdm", new { jhlbdm = row["jhlbdm"] });
                        myData.kldm = Convert.ToString(row["jhlbdm"]);
                    }
                    else
                    {
                        myData.kl = Getfv<string>("td_kldm", "klmc", "kldm=@kldm", new { kldm = row["kldm"] });
                        myData.kldm = Convert.ToString(row["kldm"]);
                    }

                    myData.zjhm = (string)row["zjhm"];
                    myData.tzcj = Convert.ToString(row["tzcj"]);
                    myData.tdcj = Convert.ToString(row["tdcj"]);
                    myData.tdcjqz = row["tdcj"] is DBNull ? "" : Math.Floor(Convert.ToDouble(row["tdcj"])).ToString();
                    myData.wyyz = Getfv<string>("td_wyyzdm", "wyyzmc", "wyyzdm=@wyyzdm", new { wyyzdm = row["wyyzdm"] });
                    myData.wytl = Convert.ToString(row["wytl"]);
                    myData.wyks = Convert.ToString(row["wyks"]);
                    myData.kstc = Convert.ToString(row["kstc"]);
                    myData.tddw = Getfv<string>("t_tddw", "tddwmc", "tddwdm=@tddwdm", new { tddwdm = row["tddwdm"] });
                    myData.fctj = Convert.ToString(row["zytj"]) == "1" ? "是" : "否";
                    if (!string.IsNullOrEmpty(Convert.ToString(row["zytjlx"]).Trim()) && Convert.ToString(row["zytjlx"]).Trim() != "?")
                    {
                        myData.tjlx = Getfv<string>("td_zytjlxdm", "zytjlxmc", "zytjlxdm=@zytjlxdm", new { zytjlxdm = row["zytjlx"] });
                    }
                    myData.zkzh = Convert.ToString(row["zkzh"]);
                    myData.csrq = Convert.ToDateTime(row["csrq"]).ToString();
                    //myData.zzmm = Getfv<string>("td_zzmmdm", "zzmmmc", "zzmmdm=@zzmmdm", new { zzmmdm = row["zzmmdm"] });
                    myData.zzmm = Convert.ToString(row["zzmm"]);
                    myData.zzmmdm = Convert.ToString(row["zzmmdm"]);
                    //myData.mz = Getfv<string>("td_mzdm", "mzmc", "mzdm=@mzdm", new { mzdm = row["mzdm"] });
                    myData.mz = Convert.ToString(row["mz"]);
                    myData.mzdm = Convert.ToString(row["mzdm"]);
                    myData.pc = Getfv<string>("td_pcdm", "pcmc", "pcdm=@pcdm", new { pcdm = row["pcdm"] });
                    myData.pcdm = Convert.ToString(row["pcdm"]);
                    myData.jhxz = Getfv<string>("td_jhxzdm", "jhxzmc", "jhxzdm=@jhxzdm", new { jhxzdm = row["jhxzdm"] });
                    myData.jhxzdm = Convert.ToString(row["jhxzdm"]);
                    myData.jhlb = Getfv<string>("td_jhlbdm", "jhlbmc", "jhlbdm=@jhlbdm", new { jhlbdm = row["jhlbdm"] });
                    myData.jhlbdm = Convert.ToString(row["jhlbdm"]);
                    myData.kslb = Getfv<string>("td_kslbdm", "kslbmc", "kslbdm=@kslbdm", new { kslbdm = row["kslbdm"] });
                    myData.kslbdm = Convert.ToString(row["kslbdm"]);
                    myData.bylb = Getfv<string>("td_bylbdm", "bylbmc", "bylbdm=@bylbdm", new { bylbdm = row["bylbdm"] });
                    myData.bylbdm = Convert.ToString(row["bylbdm"]);
                    myData.byxxmc = Convert.ToString(row["byxxmc"]);
                    myData.byxxdm = Convert.ToString(row["byxxdm"]);
                    myData.ysjz = Convert.ToString(row["ysjzdm"]);
                    myData.bmdw = Getfv<string>("td_bmdwdm", "bmdwmc", "bmdw=@bmdw", new { bmdw = row["bmdw"] });
                    myData.ksdq = Getfv<string>("td_dqdm", "dqmc", "dqdm=@dqdm", new { dqdm = row["dqdm"] });
                    myData.ksdqdm = Convert.ToString(row["dqdm"]);
                    myData.kshj = Getfv<string>("td_dqdm", "dqmc", "dqdm=@dqdm", new { dqdm = row["hjdm"] });
                    myData.hjlb = Getfv<string>("td_hjlbdm", "hjlbmc", "hjlbdm=@hjlbdm", new { hjlbdm = row["hjlbdm"] });
                    myData.kshjdm = Convert.ToString(row["hjdm"]);
                    myData.zjlx = Getfv<string>("td_zjlxdm", "zjlxmc", "zjlxdm=@zjlxdm", new { zjlxdm = row["zjlxdm"] });
                    myData.xjh = Convert.ToString(row["xjh"]);
                    myData.txdz = Convert.ToString(row["txdz"]);
                    myData.lxsj = Convert.ToString(row["lxsj"]);
                    myData.lxdh = Convert.ToString(row["lxdh"]);
                    myData.sjr = Convert.ToString(row["sjr"]);
                    myData.yzbm = Convert.ToString(row["yzbm"]);
                    myData.ksjlhcf = Convert.ToString(row["ksjlhcf"]);
                    myData.sxpdkhyj = Convert.ToString(row["sxpdkhyj"]);
                    myData.tddbh = Convert.ToString(row["tddbh"]);
                    myData.bz = Convert.ToString(row["bz"]);
                    myData.tfpw = Convert.ToString(row["zycjtfpw"]);
                    myData.xkkm = Getxkkm(Convert.ToString(row["xkkm"]));
                    myData.createtime = Convert.ToString(DateTimeOffset.Now.ToUnixTimeSeconds());
                    myData.updatetime = Convert.ToString(DateTimeOffset.Now.ToUnixTimeSeconds());




                    if (!string.IsNullOrEmpty(Convert.ToString(row["zytz"]).Trim()) && Convert.ToString(row["zytz"]).Trim() != "?")
                    {
                        myData.zytz = Getfv<string>("td_zytzdm", "zytzmc", "zytzdm=@zytzdm", new { zytzdm = row["zytz"] });
                    }
                    if (!string.IsNullOrEmpty(Convert.ToString(row["tdlxdm"]).Trim()) && Convert.ToString(row["tdlxdm"]).Trim() != "?")
                    {
                        myData.tdlx = Getfv<string>("td_tdlxdm", "tdlxmc", "tdlxdm=@tdlxdm", new { tdlxdm = row["tdlxdm"] });
                        myData.tdlxdm = Convert.ToString(row["tdlxdm"]);
                    }
                    myData.tdsj = row["tdsj"] is DBNull ? null : Convert.ToDateTime(row["tdsj"]).ToString();
                    if (!string.IsNullOrEmpty(Convert.ToString(row["ytzy"]).Trim()) && Convert.ToString(row["ytzy"]).Trim() != "?")
                    {
                        myData.ytzy = Getfv<string>("td_zydh", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = row["ytzy"], kldm = row["kldm"] });
                    }
                    myData.lqsj = row["lqsj"] is DBNull ? null : Convert.ToDateTime(row["lqsj"]).ToString();
                    if (!string.IsNullOrEmpty(Convert.ToString(row["lqzy"]).Trim()) && Convert.ToString(row["lqzy"]).Trim() != "?")
                    {

                        myData.lqlx = Getfv<string>("td_lqlxdm", "lqlxmc", "lqlxdm=@lqlxdm", new { lqlxdm = row["lqlxdm"] });
                        myData.lqlxdm = Convert.ToString(row["lqlxdm"]);
                        var lqzyarr = Getfvlist("td_zydh", "zymc,ccdm,xzdm", "zydh=@zydh and kldm=@kldm", new { zydh = row["lqzy"], kldm = row["kldm"] });
                        myData.lqzydh = Convert.ToString(row["lqzy"]);
                        myData.jhid = Getfv<string>("t_jhk", "jhid", "zydh=@zydh and kldm=@kldm", new { zydh = row["lqzy"], kldm = row["kldm"] });
                        //Console.WriteLine(lqzyarr.Rows[0]["zymc"]);//打印第一行的zymc字段
                        myData.lqzy = Convert.ToString(lqzyarr.Rows[0]["zymc"]).Trim();
                        myData.lqzydm = Getfv<string>("td_zydhdmdz", "zydm", "zydh=@zydh and kldm=@kldm", new { zydh = row["lqzy"], kldm = row["kldm"] });
                        myData.xz = Getfv<string>("td_xzdm", "xzmc", "xzdm=@xzdm", new { xzdm = lqzyarr.Rows[0]["xzdm"] });
                        myData.ccdm = Convert.ToString(lqzyarr.Rows[0]["ccdm"]).Trim();
                        myData.cc = Getfv<string>("td_ccdm", "ccmc", "ccdm=@ccdm", new { ccdm = myData.ccdm });
                    }
                    myData.zyh = Convert.ToString(row["ljzyh"]);
                    myData.zgf = Convert.ToString(row["zgf"]);
                    myData.yxdycj = Convert.ToString(row["yxdycj"]);
                    myData.zyytjzcj = Convert.ToString(row["zyytjzcj"]);
                    myData.zyytfjcj = Convert.ToString(row["zyytfjcj"]);
                    var zyzy1zydh = Getfv<string>("t_zykmx", "zydh", "ksh=@ksh and zyxh=@zyxh and zydh!=''", new { ksh = row["ksh"], zyxh = 1 });
                    if (!string.IsNullOrEmpty(zyzy1zydh))
                    {
                        myData.zyzy1 = Getfv<string>("td_zydh", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy1zydh, kldm = row["kldm"] });
                        myData.zyzydm1 = Getfv<string>("td_zydhdmdz", "zydm", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy1zydh, kldm = row["kldm"] });
                    }
                    var zyzy2zydh = Getfv<string>("t_zykmx", "zydh", "ksh=@ksh and zyxh=@zyxh and zydh!=''", new { ksh = row["ksh"], zyxh = 2 });
                    if (!string.IsNullOrEmpty(zyzy2zydh))
                    {
                        myData.zyzy2 = Getfv<string>("td_zydh", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy2zydh, kldm = row["kldm"] });
                        myData.zyzydm2 = Getfv<string>("td_zydhdmdz", "zydm", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy2zydh, kldm = row["kldm"] });
                    }
                    var zyzy3zydh = Getfv<string>("t_zykmx", "zydh", "ksh=@ksh and zyxh=@zyxh and zydh!=''", new { ksh = row["ksh"], zyxh = 3 });
                    if (!string.IsNullOrEmpty(zyzy3zydh))
                    {
                        myData.zyzy3 = Getfv<string>("td_zydh", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy3zydh, kldm = row["kldm"] });
                        myData.zyzydm3 = Getfv<string>("td_zydhdmdz", "zydm", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy3zydh, kldm = row["kldm"] });
                    }
                    var zyzy4zydh = Getfv<string>("t_zykmx", "zydh", "ksh=@ksh and zyxh=@zyxh and zydh!=''", new { ksh = row["ksh"], zyxh = 4 });
                    if (!string.IsNullOrEmpty(zyzy4zydh))
                    {
                        myData.zyzy4 = Getfv<string>("td_zydh", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy4zydh, kldm = row["kldm"] });
                        myData.zyzydm4 = Getfv<string>("td_zydhdmdz", "zydm", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy4zydh, kldm = row["kldm"] });
                    }
                    var zyzy5zydh = Getfv<string>("t_zykmx", "zydh", "ksh=@ksh and zyxh=@zyxh and zydh!=''", new { ksh = row["ksh"], zyxh = 5 });
                    if (!string.IsNullOrEmpty(zyzy5zydh))
                    {
                        myData.zyzy5 = Getfv<string>("td_zydh", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy5zydh, kldm = row["kldm"] });
                        myData.zyzydm5 = Getfv<string>("td_zydhdmdz", "zydm", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy5zydh, kldm = row["kldm"] });
                    }
                    var zyzy6zydh = Getfv<string>("t_zykmx", "zydh", "ksh=@ksh and zyxh=@zyxh and zydh!=''", new { ksh = row["ksh"], zyxh = 6 });
                    if (!string.IsNullOrEmpty(zyzy6zydh))
                    {
                        myData.zyzy6 = Getfv<string>("td_zydh", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy6zydh, kldm = row["kldm"] });
                        myData.zyzydm6 = Getfv<string>("td_zydhdmdz", "zydm", "zydh=@zydh and kldm=@kldm", new { zydh = zyzy6zydh, kldm = row["kldm"] });
                    }

                    // 处理总分
                    StringBuilder sb;
                    if (sourFields["zongfen"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zongfen"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.cj = sb.ToString().Trim();
                    }
                    // 处理综合成绩
                    if (sourFields["zonghe"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zonghe"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.zh = sb.ToString().Trim();
                    }
                    // 处理语文成绩
                    if (sourFields["yuwen"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["yuwen"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.yw = sb.ToString().Trim();
                    }
                    // 处理数学成绩
                    if (sourFields["shuxue"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["shuxue"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.sx = sb.ToString().Trim();
                    }
                    // 处理外语成绩
                    if (sourFields["waiyu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["waiyu"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.wy = sb.ToString().Trim();
                    }
                    // 处理物理成绩
                    if (sourFields["wuli"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["wuli"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.wl = sb.ToString().Trim();
                    }
                    // 处理化学成绩
                    if (sourFields["huaxue"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["huaxue"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.hx = sb.ToString().Trim();
                    }
                    // 处理生物成绩
                    if (sourFields["shengwu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["shengwu"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.sw = sb.ToString().Trim();
                    }
                    // 处理政治成绩
                    if (sourFields["zhengzhi"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zhengzhi"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.zz = sb.ToString().Trim();
                    }
                    // 处理历史成绩
                    if (sourFields["lishi"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["lishi"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.ls = sb.ToString().Trim();
                    }
                    // 处理地理成绩
                    if (sourFields["dili"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["dili"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.dl = sb.ToString().Trim();
                    }
                    // 处理技术成绩
                    if (sourFields["jishu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["jishu"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.js = sb.ToString().Trim();
                    }
                    // 处理专业课成绩
                    if (sourFields["zhuanyeke"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zhuanyeke"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.zhuanyeke = sb.ToString().Trim();
                    }
                    // 处理外语成绩
                    if (sourFields["waiyu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["waiyu"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.wy = sb.ToString().Trim();
                    }
                    // 处理生命科学成绩
                    if (sourFields["shengmingkexue"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["shengmingkexue"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.smkx = sb.ToString().Trim();
                    }
                    // 处理民族语文成绩
                    if (sourFields["minzuyuwen"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["minzuyuwen"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.minzuyuwen = sb.ToString().Trim();
                    }
                    // 处理全国性政策加分
                    if (sourFields["qgxzcjf"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["qgxzcjf"])
                        {
                            if (dtf.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.qgxzcjf = sb.ToString().Trim();
                    }
                    // todo 处理成绩 fdb


                    datas.Add(myData);
                    //}
                }
            }
            else
            {
                // 将数据库查询的数据变成一个表格(这个表格里存的就是数据库的原始值了)
                DataTable dt = base.GetDataTable(sql);
                foreach (DataRow row in dt.Rows) // 遍历这个表格的每行数据
                {

                    MyData myData = new MyData();
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["lqzy"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["lqzy"]).Replace("\0", "").Trim() != "?")
                    {
                        myData.zslqztdm = "1";
                    }
                    else
                    {
                        myData.zslqztdm = "0";
                    }
                    myData.year = (string)row["year"];
                    myData.ksh = (string)row["ksh"];
                    myData.xm = (string)row["xm"];
                    //myData.xb = Getfv<string>("TD_XBDM", "XBMC", "XBDM=@xbdm", new { xbdm = (byte[])row["xbdm"] });
                    myData.xb = Convert.ToString(row["xb"]);
                    myData.xbdm = Encoding.ASCII.GetString((byte[])row["xbdm"]).Replace("\0", "");//将性别代码二进制值传成字符串代码
                    myData.zsdiqu = (string)row["zsdiqu"];
                    myData.zsdiqudm = (string)row["zsdiqudm"];
                    myData.kl = Getfv<string>("td_kldm", "klmc", "kldm=@kldm", new { kldm = (byte[])row["kldm"] });
                    myData.kldm = Encoding.ASCII.GetString((byte[])row["kldm"]).Replace("\0", "");
                    myData.zjhm = (string)row["sfzh"];
                    myData.tzcj = (string)row["tzcj"].ToString();
                    myData.tdcj = (string)row["tdcj"].ToString();
                    myData.tdcjqz = row["tdcj"] is DBNull ? "" : Math.Floor(Convert.ToDouble(row["tdcj"])).ToString();
                    myData.yyky = "";
                    myData.wytl = Convert.ToString(row["wytl"]);
                    myData.wyks = Convert.ToString(row["wyks"]);
                    myData.kstc = Convert.ToString(row["kstc"]);
                    myData.tddw = Getfv<string>("t_tddw", "tddwmc", "tddwdm=@tddwdm", new { tddwdm = (byte[])row["tddw"] });
                    myData.fctj = Convert.ToString(row["zyzytj"]) == "1" ? "是" : "否";
                    myData.tjlx = Convert.ToString(row["dxtj"]);
                    myData.zkzh = row["zkzh"]?.ToString();
                    myData.csrq = Convert.ToDateTime(row["csny"]).ToString();
                    //myData.zzmm = Getfv<string>("td_zzmmdm", "zzmmmc", "zzmmdm=@zzmmdm", new { zzmmdm = (byte[])row["zzmmdm"]});
                    myData.zzmm = Convert.ToString(row["zzmm"]);
                    myData.zzmmdm = Encoding.ASCII.GetString((byte[])row["zzmmdm"]).Replace("\0", "");
                    //myData.mz = Getfv<string>("td_mzdm", "mzmc", "mzdm=@mzdm", new { mzdm = (byte[])row["mzdm"] });
                    myData.mz = Convert.ToString(row["mz"]);
                    myData.mzdm = Encoding.ASCII.GetString((byte[])row["mzdm"]).Replace("\0", "");
                    myData.pc = Getfv<string>("td_pcdm", "pcmc", "pcdm=@pcdm", new { pcdm = (byte[])row["pcdm"] });
                    myData.pcdm = Encoding.ASCII.GetString((byte[])row["pcdm"]).Replace("\0", "");
                    myData.jhxz = Getfv<string>("td_jhxzdm", "jhxzmc", "jhxzdm=@jhxzdm", new { jhxzdm = (byte[])row["jhxz"] });
                    myData.jhxzdm = Encoding.ASCII.GetString((byte[])row["jhxz"]).Replace("\0", "");
                    myData.kslb = Getfv<string>("td_kslbdm", "kslbmc", "kslbdm=@kslbdm", new { kslbdm = (byte[])row["kslbdm"] });
                    myData.kslbdm = Encoding.ASCII.GetString((byte[])row["kslbdm"]).Replace("\0", "");
                    myData.bylb = Getfv<string>("td_bylbdm", "bylbmc", "bylbdm=@bylbdm", new { bylbdm = (byte[])row["bylbdm"] });
                    myData.bylbdm = Encoding.ASCII.GetString((byte[])row["bylbdm"]).Replace("\0", "");
                    myData.byxxmc = Convert.ToString(row["zxmc"]);
                    myData.byxxdm = Convert.ToString(row["zxdm"]);
                    myData.ysjz = Encoding.ASCII.GetString((byte[])row["ysjzdm"]).Replace("\0", "");
                    myData.bmdw = Convert.ToString(row["bmdw"]);
                    myData.ksdq = Getfv<string>("td_dqdm", "dqmc", "dqdm=@dqdm", new { dqdm = (byte[])row["dqdm"] });
                    myData.ksdqdm = Encoding.ASCII.GetString((byte[])row["dqdm"]).Replace("\0", "");
                    myData.kshj = Getfv<string>("td_dqdm", "dqmc", "dqdm=@dqdm", new { dqdm = (byte[])row["dqdm"] });
                    myData.kshjdm = Encoding.ASCII.GetString((byte[])row["dqdm"]).Replace("\0", "");
                    myData.txdz = Convert.ToString(row["jtdz"]);
                    myData.lxsj = Convert.ToString(row["lxdh"]);
                    myData.lxdh = Convert.ToString(row["lxdh"]);
                    myData.sjr = Convert.ToString(row["sjr"]);
                    myData.yzbm = Convert.ToString(row["yzbm"]);
                    myData.ksjlhcf = Convert.ToString(row["ksjlhcf"]);
                    myData.sxpdkhyj = Convert.ToString(row["zsyj"]);
                    myData.tjjl = Convert.ToString(row["tjjldm"]);
                    myData.tddbh = Convert.ToString(row["bh"]);
                    myData.bz = Convert.ToString(row["bz"]);
                    myData.zytz = Convert.ToString(row["zytz"]);
                    myData.tdsj = null;
                    myData.createtime = Convert.ToString(DateTimeOffset.Now.ToUnixTimeSeconds());
                    myData.updatetime = Convert.ToString(DateTimeOffset.Now.ToUnixTimeSeconds());
                    string ytzypd = Encoding.ASCII.GetString((byte[])row["ytzy"]).Replace("\0", "").Trim();
                    if (!string.IsNullOrEmpty(ytzypd) && ytzypd != "?")
                    {
                        myData.ytzy = Getfv<string>("t_jhk", "zymc", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["ytzy"], kldm = (byte[])row["kldm"] }).Trim();
                    }

                    //var lqzyarr = Getfvlist("t_jhk", "zymc,zydm", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["lqzy"], kldm = (byte[])row["kldm"] });
                    //Console.WriteLine(lqzyarr.Rows[0]["zymc"]);//打印第一行的zymc字段
                    //Console.WriteLine(lqzyarr.Rows[0]["zydm"]);// 打印第一行的zydm字段
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["lqzy"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["lqzy"]).Replace("\0", "").Trim() != "?")
                    {
                        myData.lqsj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        myData.lqlx = Getfv<string>("td_lqfsdm", "lqfsmc", "lqfsdm=@lqfsdm", new { lqfsdm = (byte[])row["lqfs"] });
                        myData.lqlxdm = Encoding.ASCII.GetString((byte[])row["lqfs"]).Replace("\0", "");
                        var lqzyarr = Getfvlist("t_jhk", "zymc,zydm,xznx", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["lqzy"], kldm = (byte[])row["kldm"] });
                        myData.lqzydh = Encoding.ASCII.GetString((byte[])row["lqzy"]).Replace("\0", "");
                        myData.lqzy = Convert.ToString(lqzyarr.Rows[0]["zymc"]).Trim();
                        myData.lqzydm = Convert.ToString(lqzyarr.Rows[0]["zydm"]).Trim();
                        myData.xz = Convert.ToString(lqzyarr.Rows[0]["xznx"]).Trim(); ;
                    }
                    else
                    {
                        myData.lqsj = null;
                    }
                    myData.zyh = Convert.ToString(row["tdzy"]);
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["zydh1"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["zydh1"]).Replace("\0", "").Trim() != "?")
                    {
                        var zyzy1arr = Getfvlist("t_jhk", "zymc,zydm", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["zydh1"], kldm = (byte[])row["kldm"] });
                        myData.zyzy1 = Convert.ToString(zyzy1arr.Rows[0]["zymc"]).Trim();
                        myData.zyzydm1 = Convert.ToString(zyzy1arr.Rows[0]["zydm"]).Trim();
                    }
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["zydh2"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["zydh2"]).Replace("\0", "").Trim() != "?")
                    {
                        var zyzy2arr = Getfvlist("t_jhk", "zymc,zydm", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["zydh2"], kldm = (byte[])row["kldm"] });
                        myData.zyzy2 = Convert.ToString(zyzy2arr.Rows[0]["zymc"]).Trim();
                        myData.zyzydm2 = Convert.ToString(zyzy2arr.Rows[0]["zydm"]).Trim();
                    }
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["zydh3"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["zydh3"]).Replace("\0", "").Trim() != "?")
                    {
                        var zyzy3arr = Getfvlist("t_jhk", "zymc,zydm", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["zydh3"], kldm = (byte[])row["kldm"] });
                        myData.zyzy3 = Convert.ToString(zyzy3arr.Rows[0]["zymc"]).Trim();
                        myData.zyzydm3 = Convert.ToString(zyzy3arr.Rows[0]["zydm"]).Trim();
                    }
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["zydh4"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["zydh4"]).Replace("\0", "").Trim() != "?")
                    {
                        var zyzy4arr = Getfvlist("t_jhk", "zymc,zydm", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["zydh4"], kldm = (byte[])row["kldm"] });
                        myData.zyzy4 = Convert.ToString(zyzy4arr.Rows[0]["zymc"]).Trim();
                        myData.zyzydm4 = Convert.ToString(zyzy4arr.Rows[0]["zydm"]).Trim();
                    }
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["zydh5"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["zydh5"]).Replace("\0", "").Trim() != "?")
                    {
                        var zyzy5arr = Getfvlist("t_jhk", "zymc,zydm", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["zydh5"], kldm = (byte[])row["kldm"] });
                        myData.zyzy5 = Convert.ToString(zyzy5arr.Rows[0]["zymc"]).Trim();
                        myData.zyzydm5 = Convert.ToString(zyzy5arr.Rows[0]["zydm"]).Trim();
                    }
                    if (!string.IsNullOrEmpty(Encoding.ASCII.GetString((byte[])row["zydh6"]).Replace("\0", "").Trim()) && Encoding.ASCII.GetString((byte[])row["zydh6"]).Replace("\0", "").Trim() != "?")
                    {
                        var zyzy6arr = Getfvlist("t_jhk", "zymc,zydm", "zydh=@zydh and kldm=@kldm", new { zydh = (byte[])row["zydh6"], kldm = (byte[])row["kldm"] });
                        myData.zyzy6 = Convert.ToString(zyzy6arr.Rows[0]["zymc"]).Trim();
                        myData.zyzydm6 = Convert.ToString(zyzy6arr.Rows[0]["zydm"]).Trim();
                    }

                    // 处理总分
                    StringBuilder sb;
                    if (sourFields["zongfen"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zongfen"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.cj = sb.ToString().Trim();
                    }
                    // 处理综合成绩
                    if (sourFields["zonghe"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zonghe"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.zh = sb.ToString().Trim();
                    }
                    // 处理语文成绩
                    if (sourFields["yuwen"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["yuwen"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.yw = sb.ToString().Trim();
                    }
                    // 处理数学成绩
                    if (sourFields["shuxue"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["shuxue"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.sx = sb.ToString().Trim();
                    }
                    // 处理外语成绩
                    if (sourFields["waiyu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["waiyu"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.wy = sb.ToString().Trim();
                    }
                    // 处理物理成绩
                    if (sourFields["wuli"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["wuli"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.wl = sb.ToString().Trim();
                    }
                    // 处理化学成绩
                    if (sourFields["huaxue"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["huaxue"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.hx = sb.ToString().Trim();
                    }
                    // 处理生物成绩
                    if (sourFields["shengwu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["shengwu"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.sw = sb.ToString().Trim();
                    }
                    // 处理政治成绩
                    if (sourFields["zhengzhi"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zhengzhi"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.zz = sb.ToString().Trim();
                    }
                    // 处理历史成绩
                    if (sourFields["lishi"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["lishi"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.ls = sb.ToString().Trim();
                    }
                    // 处理地理成绩
                    if (sourFields["dili"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["dili"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.dl = sb.ToString().Trim();
                    }
                    // 处理技术成绩
                    if (sourFields["jishu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["jishu"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.js = sb.ToString().Trim();
                    }
                    // 处理专业课成绩
                    if (sourFields["zhuanyeke"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["zhuanyeke"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.zhuanyeke = sb.ToString().Trim();
                    }
                    // 处理外语成绩
                    if (sourFields["waiyu"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["waiyu"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.wy = sb.ToString().Trim();
                    }
                    // 处理生命科学成绩
                    if (sourFields["shengmingkexue"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["shengmingkexue"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.smkx = sb.ToString().Trim();
                    }
                    // 处理民族语文成绩
                    if (sourFields["minzuyuwen"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["minzuyuwen"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.minzuyuwen = sb.ToString().Trim();
                    }
                    // 处理全国性政策加分
                    if (sourFields["qgxzcjf"] != null)
                    {
                        sb = new StringBuilder();
                        foreach (var fd in sourFields["qgxzcjf"])
                        {
                            if (dt.Columns.Contains(fd))
                            {
                                sb.Append(row[fd]);
                            }
                        }
                        myData.qgxzcjf = sb.ToString().Trim();
                    }

                    // todo 处理成绩 mdb

                    datas.Add(myData);
                    //}
                }
            }
            return datas;
        }

        /// <summary>
        /// 获取查询SQL语句(dapper专用)
        /// </summary>
        /// <returns></returns>
        private string GetSQL()
        {
            StringBuilder sb = new StringBuilder();
            var area = _Areas.FirstOrDefault(t => t.AreaCode == _File.AreaCode);
            if (area == null) return sb.ToString();
            if (_File.FileExtension.ToLower() == ".mdb") // Access数据库
            {
                // todo 这里就sql语句需要自行修改
                sb.Append($"select '{_Option.Year}' as [year],'{area.AreaName}' as zsdiqu,'{area.AreaCode}' as zsdiqudm,t2.xbmc as xb,t3.zzmmmc as zzmm,t4.mzmc as mz,t1.* from (((t_tdd t1 left join td_xbdm t2 on t1.xbdm=t2.xbdm) left join td_zzmmdm t3 on t1.zzmmdm=t3.zzmmdm) left join td_mzdm t4 on t1.mzdm=t4.mzdm)");
                //sb.Append($"select '{_Option.Year}' as [year],ksh,xm,xbmc as xb,t1.xbdm,'{area.AreaName}' as zsdiqu,'{area.AreaCode}' as zsdiqudm,t3.klmc as kl,t1.kldm,sfzh as zjhm,tzcj,tdcj,gkcjx09 as yyky,wytl,wyks,kstc,t11.tddwmc as tddw,t1.zyzytj as fctj,dxtj as tjlx,zkzh,csny as csrq,t4.zzmmmc as zzmm,t1.zzmmdm,t5.mzmc as mz,t1.mzdm,t6.pcmc as pc,t1.pcdm,t7.jhxzmc as jhxz,t1.jhxz as jhxzdm,t8.kslbmc as kslb,t1.kslbdm,t9.bylbmc as bylb,t1.bylbdm,t1.zxmc as byxxmc,t1.zxdm as byxxdm,t1.ysjzdm as ysjz,t1.bmdw,t10.dqmc as ksdq,t1.dqdm as ksdqdm,t1.jtdz as txdz,t1.lxdh,t1.sjr,t1.yzbm,t1.ksjlhcf,t1.zsyj as sxpdkhyj,t1.tjjldm as tjjl,t1.bh as tddbh,t1.bz,zytz,ytzy,t1.lqfs as lqlxdm,t12.lqfsmc as lqlx,t13.zymc as lqzy,t1.lqzy as lqzydh,t13.zydm as lqzydm,t13.xznx as xz,t1.tdzy as zyh from ((((((((((((t_tdd t1 left join td_xbdm t2 on t1.xbdm=t2.xbdm) left join td_kldm t3 on t1.kldm=t3.kldm) left join td_zzmmdm t4 on t1.zzmmdm=t4.zzmmdm) left join td_mzdm t5 on t1.mzdm=t5.mzdm) left join td_pcdm t6 on t1.pcdm=t6.pcdm) left join td_jhxzdm t7 on t1.jhxz=t7.jhxzdm) left join td_kslbdm t8 on t1.kslbdm=t8.kslbdm) left join td_bylbdm t9 on t1.bylbdm=t9.bylbdm) left join td_dqdm t10 on t1.dqdm=t10.dqdm) left join t_tddw t11 on (t1.tddw=t11.tddwdm  and t1.pcdm=t11.pcdm and t1.kldm=t11.kldm and t1.jhxz=t11.jhxz)) left join td_lqfsdm t12 on t1.lqfs=t12.lqfsdm) left join t_jhk t13 on (t1.lqzy=t13.zydh and t1.pcdm=t13.pcdm and t1.kldm=t13.kldm and t1.jhxz=t13.jhxz and t1.tddw=t13.tddw))");

            }
            else if (_File.FileExtension.ToLower() == ".fdb")// 火鸟数据库
            {
                // todo 这里就sql语句需要自行修改
                sb.Append($"select  '{_Option.Year}' \"year\",'{area.AreaName}' \"zsdiqu\",'{area.AreaCode}' \"zsdiqudm\",t2.kldm kldm,t1.*,t2.*,t3.xbmc \"xb\",t4.mzmc mz,t5.zzmmmc zzmm from ((((t_bmk t1 join t_tdd t2 ON t1.ksh=t2.ksh) left join td_xbdm t3 on t1.xbdm=t3.xbdm) left join td_mzdm t4 on t1.mzdm=t4.mzdm) left join td_zzmmdm t5 on t1.zzmmdm=t5.zzmmdm)");
                //sb.Append($"select '{_Option.Year}' \"year\",t1.ksh,t1.xm,t1.xbdm,t3.xbmc \"xb\",t4.klmc  kl,t1.kldm,'{area.AreaName}' \"zsdiqu\",'{area.AreaCode}' \"zsdiqudm\",zjhm,t2.tzcj,t2.tdcj,t5.wyyzmc wyyz,t1.wytl,t1.wyks,t1.kstc,t2.tddwdm tddw,t1.zkzh,t1.csrq,t7.zzmmmc zzmm,t1.zzmmdm,t8.mzmc mz,t1.mzdm,t9.pcmc pc,t2.pcdm,t10.jhxzmc jhxz,t2.jhxzdm,t11.jhlbmc jhlb,t2.jhlbdm,t12.kslbmc kslb,t1.kslbdm,t13.bylbmc bylb,t1.bylbdm,t1.byxxmc,t1.byxxdm,t1.ysjzdm ysjz,t14.bmdwmc bmdw,t15.dqmc ksdq,t1.dqdm ksdqdm,t16.dqmc kshj,t1.hjdm kshjdm,t17.zjlxmc zjlx,t1.xjh,t1.txdz,t1.lxsj,t1.lxdh,t1.sjr,t1.yzbm,t1.ksjlhcf,t1.sxpdkhyj,t2.zgf,t2.yxdycj,t2.zyytjzcj,t2.zyytfjcj,t2.lqsj,t18.kszgmc kszg from ((((((((((((((((t_bmk t1 left join t_tdd t2 on t1.ksh=t2.ksh) left join td_xbdm t3 on t1.xbdm=t3.xbdm)  left join td_kldm t4 on t1.kldm=t4.kldm) left join td_wyyzdm t5 on t1.wyyzdm=t5.wyyzdm)  left join td_zzmmdm t7 on t1.zzmmdm=t7.zzmmdm) left join td_mzdm t8 on t1.mzdm=t8.mzdm)  left join td_pcdm t9 on t2.pcdm=t9.pcdm)  left join td_jhxzdm t10 on t2.jhxzdm=t10.jhxzdm)  left join td_jhlbdm t11 on t2.jhlbdm=t11.jhlbdm)  left join td_kslbdm t12 on t1.kslbdm=t12.kslbdm)  left join td_bylbdm t13 on t1.bylbdm=t13.bylbdm)  left join td_bmdwdm t14 on t1.bmdw=t14.bmdw)  left join td_dqdm t15 on t1.dqdm=t15.dqdm)  left join td_dqdm t16 on t1.hjdm=t16.dqdm)  left join td_zjlxdm t17 on t1.zjlxdm=t17.zjlxdm)  left join td_kszgdm t18 on t1.kszg=t18.kszgdm)");
            }
            else
            {
                sb = new StringBuilder();

            }
            return sb.ToString();
        }

        /// <summary>
        /// 获取需要标记或还原的数据
        /// </summary>
        /// <returns></returns>
        public List<MarkData> GetMarkData()
        {
            string sql;
            if (_File.FileExtension.ToLower() == ".mdb")
            {
                sql = "select ksh,xm from t_tdd";
            }
            else
            {
                sql = "select ksh,xm from t_bmk";
            }
            return _DBConnection.Query<MarkData>(sql).ToList();
        }

        /// <summary>
        /// 更新需要标记的字段
        /// </summary>
        /// <param name="markData"></param>
        /// <returns></returns>
        public bool UpdateMark(MarkData markData)
        {
            string sql;
            if (_File.FileExtension.ToLower() == ".mdb")
            {
                sql = "update t_tdd set xm=@xm where ksh=@ksh";
            }
            else
            {
                sql = "update t_bmk set xm=@xm where ksh=@ksh";
            }
            var count = _DBConnection.Execute(sql, new { xm = markData.xm, ksh = markData.ksh });
            return count == 1;
        }

    }
}
